﻿using UnityEditor.Build;
using UnityEngine;

class XPreBuild : IPostprocessBuildWithReport, IPreprocessBuildWithReport
{
    public int callbackOrder { get; set; }

    public void OnPreprocessBuild(UnityEditor.Build.Reporting.BuildReport report)
    {
        // build前
        Debug.Log("build 前");
    }

    public void OnPostprocessBuild(UnityEditor.Build.Reporting.BuildReport report)
    {
        // build完成后
        Debug.Log("build 后");
    }
}
/*
 
- todo: Use Asset Database 时，不需要检测热更
- todo: 热更途中退出游戏，重进游戏时，需要清catalog缓存目录（要不然，Addressables会静默下载）

- build update
```
            //生成 差异组bundle
            var path = UnityEditor.AddressableAssets.Build.ContentUpdateScript.GetContentStateDataPath(true);
            if (!string.IsNullOrEmpty(path))
            {
                //删除没用的组bundle
                //if (Directory.Exists(buildPath))
                //{
                //    var bundleFiles = Directory.GetFiles(buildPath, "*.bundle");
                //    foreach (var bundleFile in bundleFiles)
                //    {
                //        Debug.Log("Del:" + bundleFile);
                //        File.Delete(bundleFile);
                //    }
                //}

                UnityEditor.AddressableAssets.Build.ContentUpdateScript.BuildContentUpdate(UnityEditor.AddressableAssets.AddressableAssetSettingsDefaultObject.Settings, path);
            }
```
 */